using Microsoft.Extensions.DependencyInjection;
using Puppy.Modularity;
using Puppy.Threading;

namespace Puppy.TestApp
{
    public class TestAppModule : PuppyModule
    {
        public override void OnApplicationInitialization(ServiceProviderAccessorContext context)
        {
            SeedTestData(context);
        }

        private static void SeedTestData(ServiceProviderAccessorContext context)
        {
            using (var scope = context.ServiceProvider.CreateScope())
            {
                AsyncHelper.RunSync(() => scope.ServiceProvider
                    .GetRequiredService<TestDataBuilder>()
                    .BuildAsync());
            }
        }
    }
}
